﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class MainButton : MonoBehaviour {

    public Button NewGameBt;
    public Button LevelSelectBt;
    public Button SetButton;
    public Button Back;
    public GameObject LevelChoose;
    public GameObject Main;

	// Use this for initialization
	void Start ()
    {
        int i = PlayerPrefs.GetInt("MusicNum", 0);
        if (i == 1)
        {
            Camera.main.GetComponent<AudioListener>().enabled = false;
        }

        NewGameBt.onClick.AddListener(NewGame);
        LevelSelectBt.onClick.AddListener(LevelSelect);
        SetButton.onClick.AddListener(Set);
        Back.onClick.AddListener(BackInit);
	}
	
	void NewGame()
    {
        Time.timeScale = 1;
        SceneManager.LoadScene("001");
    }

    void LevelSelect()
    {
        LevelChoose.SetActive(true);
        Main.SetActive(false);
    }

    void Set()
    {
        Instantiate(Resources.Load("Prefabs/UI/Setting"), gameObject.transform);  
    }

    void BackInit()
    {
        LevelChoose.SetActive(false);
        Main.SetActive(true);
    }
}
